package o.json;

public class JSONNumber extends JSONValue {
	private Number value;

	public JSONNumber(Number value) {
		this.value = value;
	}

	public Number getValue() {
		return value;
	}

	public void setValue(Number value) {
		this.value = value;
	}

	@Override
	public boolean isNumber() {
		return true;
	}

	@Override
	public JSONNumber getNumber() throws JSONException {
		return this;
	}

	@Override
	public boolean equals(Object object) {
		if (object == this) return true;
		if (object instanceof JSONNumber) {
			return equals((JSONNumber) object);
		}

		return false;
	}
	private boolean equals(JSONNumber that) {
		return this.value.equals(that.value);
	}

	@Override
	public int hashCode() {
		return value.hashCode();
	}

	@Override
	public String toString() {
		return value.toString();
	}
}
